<script setup>
import { ref,reactive, nextTick,onActivated,getCurrentInstance,onMounted, watch  } from 'vue'; 
import { useRoute,useRouter } from 'vue-router';
import { ElMessage,ElMessageBox  } from 'element-plus';

const seachTable = ref(null);
const route = useRoute();
const router = useRouter();
const instance = getCurrentInstance();

// 新增编辑回退时候刷新列表
onActivated(()=>{

})
const formInline = ref([
])

const btnLefts = ref([
    {
      label:'新建地址',
      type:'primary',
      show:()=>true,
      img:new URL("@/assets/icon/btn-add.png",import.meta.url),
      click:()=>{
        router.push({name:"AddressAdd"})
      } 
    },
])
const btnRights = ref([
])

const tableConfig = ref([
    {
      prop: "phone",
      label: "发货默认",
      type:"slot",
      slotName:'phone',
      width:100
    },
    {
      prop: "introduce",
      label: "退货默认",
      type:"slot",
      slotName:'introduce',
      width:100
    },
    {
      prop: "idCard",
      label: "联系人",
      width:100
    },
    {
      prop: "idCard",
      label: "电话号码",
      width:180
    },
    {
      prop: "idCard",
      label: "手机号码",
      width:130
    },
    {
      prop: "idCard",
      label: "所在地区",
      width:350

    },
    {
      prop: "idCard",
      label: "详细地址",
      width:550
    },
    {
      type: "action",
      label: "操作",
      width: 200,
      btns: [
        {
          label: () => "编辑",
          type:"success",
          click: async (row) => {

          },
        },
        {
          label: () => "删除",
          type:"danger",
          click: async (row) => {

          },
        },

      ],
    },
]);
const tableLoading = ref(false)
const totalPage = ref(0)
const tableData = ref([]);


const handlerSearch = async (formInline)=>{
    tableLoading.value = true;
    try{
        
        totalPage.value = 100;
        tableData.value = [
            {
                "doctorNumberCode": "YS000299",
                "type": "审方",
                "name": "12313",
                "mobile": "18207123212",
                "idCard": "",
                "frontUrl": "https://static.91medicine.net/images/20230919/2930e77d-fba7-4a7e-bbc4-f6815eca5a6d.jpg",
                "headUrl": "https://static.91medicine.net/images/20230919/f6159f8e-c44a-43cc-ae5c-3ddfc659cd7a.jpg",
                "introduce": "3123",
                "institutions": "九为（浙江）网络科技有限公司",
                "certificateUrl": "https://static.91medicine.net/images/20230919/d5e597c3-1c76-4646-a843-03b0b8686a03.jpg",
                "certificateNo": "312312",
                "titleValue": "",
                "uuid": "8a69c4628aab7785018aac0eb31f0004",
                "state": 1,
                "sfdaDoctorType": "1",
                "storeLocationUuid": "",
                "source": "3"
            },
        ];
        tableLoading.value = false;
    }catch(e){
        tableLoading.value = false;
    }
}
</script>
<template>
    <div class="page-content">
        <SeachTable 
          :tableType="1"
          ref="seachTable"

          :forms="formInline"
          :btnLefts="btnLefts"
          :btnRights="btnRights"
          :tableLoading="tableLoading"
          :tableConfig="tableConfig"
          :tableData="tableData"
          :totalPage="totalPage"
          @handlerSearch="handlerSearch"
          :tableWidth="70"
          :showLine="false"
        >
            <template #phone="{ row }">
    
                <el-switch v-model="row.phone" />
            </template>
            <template #introduce="{ row }">
                <el-switch v-model="row.introduce" />
            </template>
        </SeachTable>
    </div>
</template>
<style lang="less" scoped>
:deep(.search-table){
    .btn-area{
        padding-top:0;
    }
}
</style>